﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace WebUI.Pages
{
    public partial class editFabricante : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get credentials
            UserController usrController = new UserController();
            int secUsuario = usrController.GetUserID(User.Identity.Name);
            int secTeam = usrController.GetUserTeamID(secUsuario);

            if (secTeam != 9)
            {
                Response.Redirect("../Pages/403.aspx");
            } 

            if (!this.IsPostBack)
            {
                int idFabricante = Convert.ToInt32(Request.QueryString["id"]);

                lblID.Text = idFabricante.ToString();
                FabricanteController fabController = new FabricanteController();

                lblNome.Text = fabController.GetFabricante(idFabricante);
            }
        }

        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            FabricanteController fabController = new FabricanteController();

            fabController.UpdateFabricante(Convert.ToInt32(lblID.Text),lblNome.Text);
        }
    }
}